<template>
<el-container class="page-wrap">
    <el-header class="page-nav" height="30px">
        <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>系统管理</el-breadcrumb-item>
            <el-breadcrumb-item>机构管理</el-breadcrumb-item>
        </el-breadcrumb>
    </el-header>
    <el-main class="page-main">
        <dx-summary ref="mSummary" unit-name="uum_organ_unit">

            <template slot="parent_id_add_slot" slot-scope="scope">
                    <el-form-item :label="scope.data.column.columnLabel" :prop="scope.data.column.columnName">
                        <dx-ctrl :disabled="scope.data.column.visible=='1'?true:false" :type="scope.data.column.ctrlName"
                            @change="valueChange($event,scope.data.form,scope.data.column)"
                            @clear="valueChange($event,scope.data.form,scope.data.column)"
                            v-model="scope.data.form[scope.data.column.columnName]"
                            :code-type="scope.data.column.codeType" :clearable="true"></dx-ctrl>
                    </el-form-item>
            </template>
            <template slot="dict_code_add_slot" slot-scope="scope">
                <el-form-item :label="scope.data.column.columnLabel" :prop="scope.data.column.columnName">
                        <dx-ctrl :disabled="(scope.data.column.visible=='1' || scope.data.form.type==2)?true:false" :type="scope.data.column.ctrlName"
                            v-model="scope.data.form[scope.data.column.columnName]"
                            :code-type="scope.data.column.codeType" :clearable="true"></dx-ctrl>
                </el-form-item>
            </template>
        </dx-summary>
    </el-main>
</el-container>
</template>
<script>
import DxSummary from '../../../Common/ui/unit/dx-summary'
import DxCtrl from '../../../Common/ui/dx-ctrl'
import http from '../../../../assets/js/http.js'
import toolkit from '../../../../assets/js/toolkit.js'
export default {
    components : {
        DxSummary,
        DxCtrl
    },
    methods : {
        valueChange(val,form,col){
            if(val){
                form['parent_ids'] = val.currentNode.parent_ids + val.currentNode.id + ',';
                form['level'] = val.currentNode.level === null ||  val.currentNode.level === '' ? 0 : (val.currentNode.level + 1);
            }else{
                form['parent_id'] = 0;
                form['parent_ids'] = '0,';
                form['level'] = 0;
            }
        },
        treeNodeMethod(val,searchForm,defaultVal){
            defaultVal['parent_ids'] = val.currentNode.parent_ids + val.currentNode.id + ',';
            defaultVal['level'] = val.currentNode.level === null ||  val.currentNode.level === '' ? 0 : (val.currentNode.level + 1);
            return true;
        }
    },
    mixins : [http,toolkit]
}
</script>
<style scoped>

</style>
